SORTING RESULTS



MySQL - Sorting Results


Sorting query results is re-arranging the rows returned from a query result set either in ascending or descending order. The DESC keyword is used to sort the query result set in a descending order. The ASC keyword is used to sort the query result set in an ascending order.


Syntax :

SELECT <field1, field2,...>
FROM <table_name>
ORDER BY <field1, field2,...> ASC|DESC

  • We can sort returned result set on any column provided.

  • We can sort the result set on column or columns.

  • ASC or DESC keyword is used to get the result in ascending order or descending order accordingly.Default is ascending order.


    Example :


    SELECT StudentName,StudentClass
    FROM studentinfo
    ORDER BY StudentName,StudentClass ASC
    

    The result will be displayed as follows:
    (As we noticed Names are ordered according to ascending order of alphabets)


    StudentNameStudentclass
    Ajaashitenth
    manjusixth
    Manjushasixth
    Meherishsixth
    Noothansixth
    Sahayanasixth
    Sweekruthasixth


    MySQL TRIGGERS

    MySQL - Triggers

    posted on 2019-11-29 21:44:07 - mysql Tutorials


    Grant_ Revoke Privilege

    MySQL - Grant_ Revoke Privilege

    posted on 2019-11-26 23:15:04 - mysql Tutorials


    MySQL Vs SQL

    MySQL Vs SQL

    posted on 2019-11-25 05:02:26 - mysql Tutorials


    Prompt Examples

    ChatGPT Prompt Examples

    posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


    Use Cases

    Chat GPT Key Use Cases

    posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


    Prompt Frameworks

    Prompt Frameworks

    posted on 2023-06-21 19:33:06 - ChatGPT Tutorials